#!/usr/bin/env python  
# encoding: utf-8   

""" 
@version: v1.0 
@author: null 
@software: PyCharm 
@file: main.py 
@time: 2017.3.21 18:38 
"""

import xlrd
import xlwt

data = xlrd.open_workbook('./图灵机器人.xlsx')
table = data.sheets()[0]
trows = table.nrows

def read():
    print(trows)
    datalist = []
    for i in range(1,trows+1):
        if i%1000==0:
            write(datalist,i//1000)
            datalist.clear()
            datalist.append(table.row_values(i-1))
        else:
            datalist.append(table.row_values(i-1))
    pass

def write(data,file):
    print(file)
    workbook = xlwt.Workbook()
    worksheet = workbook.add_sheet('robot')

    for i,rowdata in enumerate(data):
        #print(i)
        #print(rowdata)
        for j,val in enumerate(rowdata):
            #print(j)
            #print(val)
            worksheet.write(i,j,label=val)
    workbook.save(str(file)+'.xls')
    pass

if __name__ == "__main__":
    read()
    #write()
    pass
